package cn.vawn.base.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Component;

import java.util.Locale;

@Component
public class MessageUtil {

    @Autowired
    protected MessageSource messageSource;

    public String getMessage(String system_language, String key) {
        Locale locale = new Locale("zh", "CN");
        if (system_language.contains("_")) {
            locale = new Locale(system_language.split("_")[0], system_language.split("_")[1]);
        }
        String value = messageSource.getMessage(key, null, locale);
        return value;
    }
}
